package com.eastfair.config.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 *
 * </p>
 *
 * @author zjn
 * @date 2021-11-19
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "FormFieldShowTypeEnum", description = "分组类型 #{perfect_Information:完善信息;details:详情-枚举")
public enum FormFieldShowTypeEnum implements BaseEnum {

    /**
     * PERFECT_INFORMATION="完善信息"
     */
    PERFECT_INFORMATION("完善信息"),
    /**
     * DETAILS="详情"
     */
    DETAILS("详情"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static FormFieldShowTypeEnum match(String val, FormFieldShowTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static FormFieldShowTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(FormFieldShowTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "PERFECT_INFORMATION,DETAILS", example = "PERFECT_INFORMATION")
    public String getCode() {
        return this.name();
    }

}
